const url = require('url')
const log4js = require('log4js');

log4js.configure({
    appenders: { cheese: { type: 'file', filename: 'cheese.log' } },
    categories: { default: { appenders: ['cheese'], level: 'error' } }
});

var logger = log4js.getLogger('cheese')
logger.level = 'debug';

const urlString = 'http://www.baidu.com:443/path/index.html?id=2&tab=4'

// console.log(url.parse(urlString));

logger.debug('url.parse(urlString)')


const urlOBJ = {
    protocol: 'http:',
    slashes: true,
    auth: null,
    host: 'www.baidu.com:443',
    port: '443',
    hostname: 'www.baidu.com',
    hash: null,
    search: '?id=2&tab=4',
    query: 'id=2&tab=4',
    pathname: '/path/index.html',
    path: '/path/index.html?id=2&tab=4',
    href: 'http://www.baidu.com:443/path/index.html?id=2&tab=4'
}

logger.debug(url.format(urlOBJ))

const urlParams = new URLSearchParams(url.parse(urlString).search)
logger.debug(urlParams.get('id'))
console.log(urlParams.get('id'));



